package com.biel.exrate.mapper;

import com.biel.exrate.entity.exchangeRateEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@Mapper
public interface exchangeRateMapper {

    @Select("select * from INFODBA.EXCHANGE_RATE")
    List<exchangeRateEntity> findAll();

    @Insert("INSERT INTO INFODBA.EXCHANGE_RATE (\"RATEDATE\", \"CURRENCYFROM\", \"CURRENCYTO\", \"LATESTRATE\") values (#{rateDate},#{currencyFrom},#{currencyTo},#{latestRate})")
    @Transactional
    void save(exchangeRateEntity exr);

    //批量插入汇率数据
    void saveBatch(List<exchangeRateEntity> list);

    //指量插入或更新汇率
    void insertOrUpdateBatch(List<exchangeRateEntity> list);
    /*
    @Update("update 'INFODBA.BIEL_EXRATE' set LatestRate=#{LatestRate},UpdateTime=#{UpdateTime} where Date=#{Date} and CurrencyFrom=#{CurrencyFrom} and CurrencyTo=#{CurrencyTo}")
    @Transactional
    void updateByKey(exrate exr);

    @Delete("delete from 'INFODBA.BIEL_EXRATE' where where Date=#{Date} and CurrencyFrom=#{CurrencyFrom} and CurrencyTo=#{CurrencyTo}")
    @Transactional
    void deleteByKey(exrate exr);

    @Select("select * from 'INFODBA.BIEL_EXRATE' where Date=#{Date} and CurrencyFrom=#{CurrencyFrom} and CurrencyTo=#{CurrencyTo}")
    exrate findByKey(exrate exr);

    @Select("select * from 'INFODBA.BIEL_EXRATE' limit #{offset},#{pCurrencyToSize}")
    List<exrate> findByPCurrencyTo(Integer offset, Integer pCurrencyToSize);

    @Select("select count(1) from 'INFODBA.BIEL_EXRATE'")
    Integer countExrate();
     */
}
